namespace _118 {

var generate = function(numRows: number): number[][] {

    var result: number[][] = []
    if (numRows === 0) return result
    result.push([1]) 
    if (numRows === 1) return result
    result.push([1, 1])
    numRows -= 2
    while(numRows > 0) {
        const last = result[result.length - 1]
        var xs = Array(2 + last.length - 1)
        for(var i = 0; i < last.length - 1; i++) {
            xs[i + 1] = last[i] + last[i+1]
        }
        xs[0] = 1
        xs[xs.length - 1] = 1
        result.push(xs)
        numRows--
    }
    
    return result
};

var answer = generate(5)
console.log('end')

}